/**
 * Copyright (c) 2016 Lenovo Group
 * All Rights Reserved.
 * 
 * Project Name:app-gateway
 * Create Time: 2016年1月18日 下午4:17:21
 */
package com.lenovo.lmrp.server.appgateway;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.lenovo.sdc.framework.rest.RestClientProxy;
import com.lenovo.sdc.framework.util.AttributeBean;

/**
 * @author zhangzhenga
 *
 */
public class RestClientFactory {

    private static final String ITSM_SCAN_PATH = "itsmgateway.scanpath";
    private static final String ITSM_REMOTE_URL = "itsmgateway.url";
    private static final String TRACE_SCAN_PATH = "assigntrace.scanpath";
    private static final String TRACE_REMOTE_URL = "assigntrace.url";
	private static final String EVENT_REVORDER_SCAN_PATH = "eventrevorder.scanpath";
	private static final String EVENT_REVORDER_REMOTE_URL = "eventrevorder.url";
	
	private final static Logger logger = LoggerFactory.getLogger(RestClientFactory.class);

	private static RestClientProxy itsmGatewayClient;
	private static RestClientProxy assignTraceClient;
	private static RestClientProxy eventRecorderClient;

	/**
	 * 
	 */
	public RestClientFactory(AttributeBean attributes) {
		itsmGatewayClient = new RestClientProxy(attributes.getAttribute(ITSM_SCAN_PATH, ""),
				attributes.getAttribute(ITSM_REMOTE_URL, ""));
		assignTraceClient = new RestClientProxy(attributes.getAttribute(TRACE_SCAN_PATH, ""),
				attributes.getAttribute(TRACE_REMOTE_URL, ""));
		try {
			eventRecorderClient = new RestClientProxy(attributes.getAttribute(EVENT_REVORDER_SCAN_PATH, ""),
					attributes.getAttribute(EVENT_REVORDER_REMOTE_URL, ""));
		} catch (Exception e) {
			logger.error(e.getMessage(),e);
		}
	}

	public static RestClientProxy getItsmGatewayClient() {
		return itsmGatewayClient;
	}

	public static RestClientProxy getAssignTraceClient() {
		return assignTraceClient;
	}

	public static RestClientProxy getEventRecorderClient() {
		return eventRecorderClient;
	}
}
